home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
LANG
/
C
/
LIB
/
UNIXLIB37B
/
!UnixLib37
/
src
/
c
/
math
< prev
next >
Wrap
Text File
|
1996-11-09
|
1KB
|
92 lines
/****************************************************************************
*
* $Source: /unixb/home/unixlib/source/unixlib37/src/c/RCS/math,v $
* $Date: 1996/10/30 21:58:59 $
* $Revision: 1.2 $
* $State: Rel $
* $Author: unixlib $
*
* $Log: math,v $
* Revision 1.2 1996/10/30 21:58:59 unixlib
* Massive changes made by Nick Burret and Peter Burwood.
*
* Revision 1.1 1996/04/19 21:26:42 simon
* Initial revision
*
***************************************************************************/
static const char rcs_id[] = "$Id: math,v 1.2 1996/10/30 21:58:59 unixlib Rel $";
#include <math.h>
#if 0
double
cosh (register double x)
{
return ((exp (x) + exp (-x)) / 2);
}
double
sinh (register double x)
{
return ((exp (x) - exp (-x)) / 2);
}
double
tanh (register double x)
{
register double x1, x2;
x1 = exp (x);
x2 = exp (-x);
return ((x1 - x2) / (x1 + x2));
}
#endif
double
frexp (register double x, register int *p)
{
register int e = 0;
if (x != 0)
{
while (x < 0.5)
{
x *= 2;
e--;
}
while (x >= 1)
{
x /= 2;
e++;
}
}
*p = e;
return (x);
}
double
fmod (double x, double y)
{
int ir, iy;
double r, w;
if (y == (double)0.0)
return (x * y) / (x * y);
r = fabs (x);
y = fabs (y);
frexp (y, &iy);
while (r >= y)
{
frexp (r, &ir);
w = ldexp (y, ir - iy);
if (w <= r)
r -= w;
else
r -= w * (double)0.5;
}
return (x >= (double)0.0) ? r : -r;
}